import request from "@/utils/request";

// 获取用户列表
export const getUserList = (data) => {
  return request({
    url: "/api/permission/Users",
    method: "GET",
    data,
  });
};
// 获取用户列表
export const newGetUserList = (data) => {
  return request({
    url: "/api/permission/Users/getUserByOrganize",
    method: "GET",
    data,
  });
};

// 审核同意
export const examine = (data) => {
  return request({
    url: "/api/permission/Users/examine",
    method: "GET",
    data,
  });
};
// 审核拒绝
export const refuse = (data) => {
  return request({
    url: "/api/permission/Users/refuse",
    method: "GET",
    data,
  });
};

//获取邀请链接
export const getInvitation = (data) => {
  return request({
    url: "/api/permission/Organize/Organize/invitation",
    method: "GET",
    data,
  });
};

//获取邀请码
export const getInvitationList = (data) => {
  return request({
    url: "/api/permission/Organize/Organize/invitation/list",
    method: "GET",
    data,
  });
};

// 获取所有用户列表
export const UserListAll = (organizeId) => {
  return request({
    url: `/api/permission/Users/All?organizeId=${organizeId}`,
    method: "GET",
  });
};

// 获取用户下拉框列表(公司+部门+用户)
export const getUserSelector = (organizeId) => {
  return request({
    url: `/api/permission/Users/Selector?organizeId=${organizeId}`,
    method: "GET",
  });
};

// 新建用户
export const createUser = (data) => {
  return request({
    url: `/api/permission/Users`,
    method: "POST",
    data,
  });
};

// 修改用户
export const updateUser = (data) => {
  return request({
    url: `/api/permission/Users/${data.id}`,
    method: "PUT",
    data,
  });
};

// 获取用户信息
export const getUserInfo = (id, organizeId) => {
  return request({
    url: `/api/permission/Users/${id}?organizeId=${organizeId}`,
    method: "GET",
  });
};

// 删除用户
export const delUser = (id, organizeId) => {
  return request({
    url: `/api/permission/Users/${id}?organizeId=${organizeId}`,
    method: "DELETE",
  });
};

// 修改用户密码
export const resetUserPassword = (data) => {
  return request({
    url: `/api/permission/Users/${data.id}/Actions/ResetPassword`,
    method: "POST",
    data,
  });
};

// 更新用户状态
export const updateUserState = (id, organizeId) => {
  return request({
    url: `/api/permission/Users/${id}/Actions/State?organizeId=${organizeId}`,
    method: "PUT",
  });
};

// IM通讯获取用户
export const getImUser = (data) => {
  return request({
    url: "/api/permission/Users/ImUser",
    method: "GET",
    data,
  });
};

// 获取用户下拉框列表
export const getImUserSelector = (organizeId, keyword) => {
  return request({
    url: `/api/permission/Users/ImUser/Selector/${organizeId}`,
    method: "post",
    data: { keyword },
  });
};

// 获取用户基本信息
export const getUserInfoList = (userId, organizeId) => {
  return request({
    url: "/api/permission/Users/getUserList",
    method: "post",
    data: { userId, organizeId },
  });
};
